package show.marvelous.domain.chessgame.repository;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import show.marvelous.domain.chessgame.aggregate.entity.PlayRecord;
import show.marvelous.infrastructure.dao.chessgame.IPlayRecordDao;
import show.marvelous.infrastructure.dao.chessgame.PlayRecordDO;
import show.marvelous.infrastructure.dao.chessgame.PlayRecordDOBuilder;

/**
 * The type Play record repository.
 * @author Kris  2021/8/24
 */
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayRecordRepository{

    private final IPlayRecordDao playRecordDao;

    /**
     * Save.
     *
     * @param playRecord the play record
     */
    public void save(long gameId, PlayRecord playRecord){
        PlayRecordDO playRecordDO = PlayRecordDOBuilder.playRecordDO().id(playRecord.getId()).gameId(gameId)
                .code(playRecord.getCode()).diceRecordId(playRecord.getDiceRecord().getId()).build();
        playRecordDao.save(playRecordDO);
    }

}
